package cn.omisheep.au.core;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author zhou xin chen  😊
 * 联系方式 qq:1269670415  email:xinchenzhou666@gmail.com
 */
@Data
@ConfigurationProperties(
        prefix = "au-config"
)
public class AuConfig {

    /**
     * 当有Au时当默认值
     */
    private String auAccessPermDefault = "user";

    /**
     * 当没有Au时，默认值
     */
    private String anyPermDefault = "any";

    /**
     * 指定一类人都不可以访问
     */
    private String forbidPermDefault = "";

    /**
     * role分隔符
     */
    private String permSeparator = ",";

    private JwtConfig jwtConfig;

    private String refreshTime = "7d"; // key刷新时间,单位 s|m|h|d

    /**
     * 全局前缀
     * server:
     * port: xxx
     * servlet:
     * context-path: /api
     * ||
     * prefix: /api
     */
    private String prefix = "";

    private ErrorConfig errorConfig = new ErrorConfig();

    @Data
    public static class JwtConfig {

        private String key; // 签名的私钥

        private String ttl = "365d"; // 存活时间,单位 s|m|h|d

    }

    /**
     * 错误返回码
     */
    @Data
    public static class ErrorConfig {

        private Integer permissionsExceptionCode = 1;

        private Integer malformedJwtExceptionCode = 2;

        private Integer signatureExceptionCode = 3;

        private Integer expiredJwtExceptionCode = 4;

        private Integer requestRepeat = 5;

    }

}
